package com.ponhu.ea2.stockcenter.provider.config;

import com.ponhu.ea2.stockcenter.enums.ExchangeActionTypeEnum;
import com.ponhu.ea2.stockcenter.provider.entity.StockWarehouseChange;
import com.ponhu.ea2.stockcenter.provider.entity.StockWarehouseChangeSettings;
import com.ponhu.ea2.stockcenter.provider.entity.StockWarehouseRelation;
import com.ponhu.ea2.stockcenter.provider.service.biz.stockwarehouse.AbsCoreHandler;
import com.ponhu.ea2.stockcenter.provider.support.enums.StockChangeInnerEventEnum;
import com.ponhu.ea2.stockcenter.provider.support.exception.StockRuntimeException;
import io.netty.util.concurrent.FastThreadLocal;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Configuration
public class AppBeanConfig {

    @Bean
    public FastThreadLocal<String> traceIdLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public FastThreadLocal<List<StockWarehouseChange>> whChangesLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public FastThreadLocal<StockChangeInnerEventEnum> saleEventLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public FastThreadLocal<Map<String, Integer>> inventoryLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public FastThreadLocal<List<StockWarehouseRelation>> whStocksLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public FastThreadLocal<StockWarehouseChangeSettings> settingsLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public FastThreadLocal<Boolean> isSaleOccupyLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public FastThreadLocal<StockRuntimeException> stockRuntimeExceptionLocal() {
        return new FastThreadLocal<>();
    }

    @Bean
    public ConcurrentHashMap<ExchangeActionTypeEnum, AbsCoreHandler> handlerPool() {
        return new ConcurrentHashMap<>();
    }

}
